package com.hctforgreen.greenservice.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * 首页菜单
 * 
 * @author dhb
 * @TIME
 */
public class MainMenuStoreUtil {

	/**
	 * 保存菜单
	 * 
	 * @param activity
	 */
	public static void save(Context activity, String funcs) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(HctConstants.MAIN_MENU_STORE_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		Editor editor = sharedPreferences.edit();
		editor.putString(HctConstants.MAIN_MENU_STORE_KEY_VALUE, funcs);
		editor.commit();
	}

	/**
	 * 删除userInfo
	 * 
	 * @param activity
	 */
	public static void delete(Activity activity) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(
				HctConstants.MAIN_MENU_STORE_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		Editor editor = sharedPreferences.edit();

		// String userInfo = change2String(entity);
		editor.putString(HctConstants.MAIN_MENU_STORE_KEY_VALUE, "");
		// editor.remove(HctConstants.LOGIN_RESULT_STORE_KEY_VALUE);
		// editor.remove(key)
		editor.commit();
	}

	/**
	 * 获取首页菜单
	 * 
	 * @param activity
	 * @return
	 */
	public static String get(Context activity) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(HctConstants.MAIN_MENU_STORE_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		String menus = sharedPreferences.getString(HctConstants.MAIN_MENU_STORE_KEY_VALUE, "");
		return menus;
	}

}
